<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>机构基础信息新增</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
<div class="Wrapper">
		<div>
			<div id="pageInTab" class="pageInTab">
			<div tabid="tabA" title="基础信息" lselected="true">
	<form id="friBaseInfo_form">
		
		<div class="fieldset1 tabel_col clearFix">
			<!-- <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder"> -->
			<div class="fieldBox col_100">
			    <div class="label">资管机构全称：</div>
				<div class="field" >
					<input name="fundRasInsNm" id="fundRasInsNm"  type="text"  class="ui-textbox" value="" validate="{required:true, maxlength:100}">
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">机构编码：</div>
				<div class="field">
					<input name="insCode" id="insCode" type="text" class="ui-textbox" value="" validate="{required:true,English:true, maxlength:20}">
					
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">机构用途：</div>
				<div class="field">
					 <input name="insUseCd" id="insUseCd" data-value="" placeholder="请选择"  ltype="combobox" validate="{required:true}">
				</div>
			</div>
			<div class="fieldBox col_100">
				<div class="label">所属事业部：</div>
				<div class="field">
					<input name="buOrgCds" id="buOrgCds"  data-value="" placeholder="请选择"  ltype="combobox" validate="{required:true}">
					
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">是否上报征信（融担主体）：</div>
				<div class="field">
					<select name="isReportZx"  id="isReportZx">
						<option value=" ">请选择 </option>
						<option value="1">否</option>
						<option value="2">是</option>
					</select>
				</div>
			</div>
			<div class="fieldBox col_50">
				<div class="label">上报征信（融担主体）：</div>
				<div class="field">
					<select name="reportZt" id="reportZt">
						<option value=" ">请选择 </option>
						<c:forEach items="${reportZtList}" var="ztitem">
						 	<option value="${ztitem.key}" > ${ztitem.value}</option>  
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">
					是否上报征信（狮桥）：</div>
				<div class="field">
					<select name="isZx" id="isZx" data-value="" validate="{required:true}">
						<option value="1">是</option>
						<option <c:if test="${sysInsCfgInfoDTO.cfgVal==0}">selected="selected"</c:if> value="0">否</option>
						
					</select>
				</div>
			</div>
			<div class="fieldBox col_50">
				<div class="label">支持的项目类型：</div>
				<div class="field">
					<input name="prjTypCds" id="prjTypCds"  data-value="" placeholder="请选择" ltype="combobox" validate="{required:true}">
					
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">
					是否开启活体验证：</div>
				<div class="field">
					<select name="isValid" id="isValid"   validate="{required:true}">
						<option <c:if test="${cmmLiveChannelRDTO.isValid==1}">selected="selected"</c:if> value="1">是</option>
						<option <c:if test="${cmmLiveChannelRDTO.isValid==0}">selected="selected"</c:if> value="0">否</option>
					</select>
				</div>
			</div>
			<div class="fieldBox col_50">
				<div class="label">
					活体类型：</div>
				<div class="field">
					<select id="liveType" name="liveType"   validate="{required:true}">
						<c:forEach items="${liveTypeList}" var="map" > 
							<option 
							<c:if test="${cmmLiveChannelRDTO == null && map.code=='1'}">selected="selected"</c:if> 
							<c:if test="${cmmLiveChannelRDTO.liveCd==map.code}">selected="selected"</c:if> 
							value="${map.code}">${map.codeNm}</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">
					是否每次签署都进行活体验证：</div>
				<div class="field">
					<select name="isEveryChk" id="isEveryChk" data-value="" validate="{required:true}">
						<option <c:if test="${cmmLiveChannelRDTO.isEveryChk==0}">selected="selected"</c:if> value="0">否</option>
						<option <c:if test="${cmmLiveChannelRDTO.isEveryChk==1}">selected="selected"</c:if> value="1">是</option>
					</select>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">业务线：</div>
				<div class="field">
					<input name="bussinessLine" id="bussinessLine" data-value="" placeholder="请选择"  ltype="combobox" >
				</div>
			</div>
			<div class="fieldBox col_33">
			</div>
			<div class="fieldBox col_33">
				<div class="label">是否支持家访费：</div>
				<div class="field">
					<select name="isVisitFee" id="isVisitFee">
						<option value=" ">请选择</option>
						<option value="1" >支持</option>
						<option value="0">不支持</option>
					</select>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">抵押方式：</div>
				<div class="field">
					<input name="mTgWay" id="mTgWay" data-value="" placeholder="请选择"  ltype="combobox" validate="{required:true}">
				</div>
			</div>
			<div class="fieldBox col_100" id="zgTextDiv" >
				<div class="label">合规提示信息：</div>
				<div class="field">
					<textarea name="zgText" id="zgText" cols="80" rows="4" class="l-textarea" style="width:560px" validate="{required:true}"></textarea>
					
				</div>
			</div>
			
			<!-- hide data -->
			<div class="fieldBox col_100" style="display:none;">
				<div class="field">
					<input name="dataId" id="dataId" type="text" class="ui-textbox" value="${id}">
				</div>
			</div>
		</div>
	<sys:funcAuth resCd="insBscInfo">
		<div class="btnsBox">
			<span id="cr_bsc_info_add_btn_id" class="sq-button sq-button-round" onclick="save();">保存 </span>
		</div>
	</sys:funcAuth>
	</form>
	
	</div>
	<sys:funcAuth resCd="insElecContract">
		<div tabid="tabB" title="电子合同" id="tabBId" style="">
			<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
		</div>
	</sys:funcAuth>
	<sys:funcAuth resCd="insQuato">
		<div tabid="tabD" title="额度管理" id="tabDId" style="">
			<iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
		</div>
	</sys:funcAuth>
	<sys:funcAuth resCd="insDeviceQuato">
		<div tabid="tabC" title="设备限额管理" id="tabCId" style="">
			<iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
		</div>
	</sys:funcAuth>

     </div>	</div></div>
	<script type="text/javascript">
	$(function() {
		
		$("#insUseCd").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
        	   data: ${insUseCdList},

	            slide: false,
	            valueField: 'key', textField: 'value',
	            valueFieldID: 'insUseCd'
        });
		$("#prjTypCds").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
     	   data: ${prjTypList},

	            slide: false,
	            valueField: 'key', textField: 'value',
	            valueFieldID: 'prjTypCds'
     });
		$("#buOrgCds").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
     	   data: ${buOrgList},

	            slide: false,
	            valueField: 'key', textField: 'value',
	            valueFieldID: 'buOrgCds'
     });
		//REQ-13543  资管机构业务线修改
		$("#bussinessLine").ligerComboBox({ 
		       data: ${bussLineList},
	           slide: false,
	           valueField: 'key', textField: 'value',
	           valueFieldID: 'bussinessLine'
		});
		//REQ-15110  资管机构抵押方式
		$("#mTgWay").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
     	   data: ${mTgWayZtList},

	            slide: false,
	            valueField: 'key', textField: 'value',
	            valueFieldID: 'mTgWay'
      });

		   $("#friBaseInfo_form").ligerForm({
                validate: true
           });

	       initData();

	       $("#isValid").change(function(){
	    	   setCanUse();
			});
	       //设置活体信息选择是否可用
		 	setCanUse();
		});

		//设置活体信息选择是否可用
		function setCanUse(){
			if($("#isValid").val() == "0") {//不可用
				liger.get("liveType").setDisabled();
				liger.get("isEveryChk").setDisabled();
			}else {//可用
				liger.get("liveType").setEnabled();
				liger.get("isEveryChk").setEnabled();
			}
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("friBaseInfo_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning("有验证信息未通过!");
                return false; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var dataId = $("#dataId").val();
            var url = '<%=path%>/rfbase/fundInsMgr/modifyNew.do';
           
           //friBaseInfoAddNew 上报征信（融担主体 必填
           
           if($.trim($("#isReportZx").val()) == ""){
        	   $.ligerDialog.SQalert({content: "是否上报征信（融担主体）不允许为空，请选择!",SQ_type: "error"});
   				return false;
           }
           
           if($.trim($("#reportZt").val()) == ""){
        	   $.ligerDialog.SQalert({content: "上报征信（融担主体）不允许为空，请选择!",SQ_type: "error"});
   				return false;
           }
           if($.trim($("#isVisitFee").val()) == ""){
        	   $.ligerDialog.SQalert({content: "是否支持家访费不允许为空，请选择!",SQ_type: "error"});
   				return false;
           }
           
           
            var ttt=data.zgText;
            	if((ttt).length>=500){
            		$.ligerDialog.alert("资管提示不能超过500字!");
                    return false; //验证不通过，不执行以下代码
            	}
            
            data["id"]=dataId;
			AjaxUtils.ajaxPost(url, data, addCallback);
		}

		//新增回调
		function addCallback(msg) {
			if (msg.success == 1) {
				UIUtils.alertSuccess(msg.info);
				/* 父级的弹出框关闭 */
				//frameElement.dialog.close();
				window.location.reload();
			} else {
				UIUtils.alertError(msg.info);
			}
		}
		
		
		//修改初始化数据
		function initData() {
			var dataId = $("#dataId").val();
			
			var _url = '<%=path%>/rfbase/fribaseinfo/getById.do';
			AjaxUtils.ajaxGet(_url, {
				id : dataId
			}, initCallback);

		}

		//初始化回调
		function initCallback(msg) {
			if (msg.success == 1) {
				setData(msg.data);//设置数据
			} else {
				UIUtils.alertError(msg.info);
			}
		}

		//修改时候设置页面数据
		function setData(data) {
			var form = new liger.get("friBaseInfo_form");
			form.setData({
				fundRasInsNm : data.fundRasInsNm,
				insCode : data.insCode,
				prjTypCds : data.prjTypCds,
				buOrgCds : data.buOrgCds,
				
				isZx :data.isZx,
				zgText : data.zgText,
				insUseCd : data.insUseCd,
				bussinessLine:data.bussinessLine,//设置 业务线 REQ-12803
				mTgWay:data.mTgWay //REQ-15110 资管机构抵押方式
			});
			
			liger.get("fundRasInsNm").setDisabled(true);
			
			if (data.insUseCd.indexOf("2") >=0) {
				liger.get("insCode").setDisabled(true);
            }
			//REQ-13452 融担主体修改
			var isReportZx = data.isReportZx; 
			var reportZt =data.reportZt;
			if(reportZt!=null && reportZt!='' &&  reportZt!='undefined'){
				liger.get("reportZt").selectValue(reportZt);
			}
			if(isReportZx!=null && isReportZx!='' &&  isReportZx!='undefined'){
				if(isReportZx == 1){//否
					liger.get("isReportZx").selectValue("1");
				}else if(isReportZx == 2){//是
					liger.get("isReportZx").selectValue("2");
				}
			}//end if
			//REQ-13176 是否支持家访费
			var isVisitFee =data.isVisitFee;
			if(isVisitFee!=null && isVisitFee!='' &&  isVisitFee!='undefined'){
				if(isVisitFee == 1){//否
					liger.get("isVisitFee").selectValue("1");
				}else if(isVisitFee == 0){//是
					liger.get("isVisitFee").selectValue("0");
				}
			}
			
			
			
		};

	</script>
	<script type="text/javascript">
	$(document).ready(function() {
		//英文
		$.validator.addMethod("English", function(value, element) {
	        return this.optional(element) || /^[a-zA-Z]+$/.test(value);
	    }, "该字段只能为英文");
	});
	</script>
	<script type="text/javascript">
	//初始化Tab
		var pageInTab = null;
	 	var loadedTabs=[];
	 	initTab();
	 	
    	function initTab(){
    	 pageInTab = $("#pageInTab").ligerTab({
             height: 'auto',
             contextmenu: false,
             minIframeHeight: GET_minIframeHeight(),
             onBeforeSelectTabItem: function (tabid) {
             	var id = "${id}";
             		//alert("id="+id);
             	 if(tabid!="tabA"){
 	             	if(id==null||id==''){
 	                	top.$.ligerDialog.SQalert({content:"请先保存项目基本信息", SQ_type: "warning"});
 	                	return false;
 	                } 
             	} 
             },
             onAfterSelectTabItem: function(tabid) {
              //   if (loadedTabs.indexOf(tabid)<0) {
                 	var id = "${id}";
                 	//alert("id="+id);
                 	 if(tabid!="tabA"){
 	                	if(id==null||id==''){
 	                		 top.$.ligerDialog.SQalert({content: LogUtils.LOG_PRJ__PRD_SELECT_BEFORE, SQ_type: "warning"});
 	                         return false; //验证不通过，不执行以下代码
 	                	}
                 	} 
                     loadedTabs.push(tabid);
                     switch (tabid){
                         case "tabA":
                        
                        	 pageInTab.setTabItemSrc(tabid, "<%=path%>/rfbase/fundInsMgr/toModifyNew.do?id="+id);
                             break;
                         case "tabB":
                              pageInTab.setTabItemSrc(tabid, "<%=path%>/ins/cont/toContConfigListPage.do?insCode="+ liger.get("insCode").getValue());
                        	  break;
                         case "tabC":
                             
                        	 pageInTab.setTabItemSrc(tabid, "<%=path%>/rfbase/fundInsMgr/toFundInsLimPage.do?id="+id);
                             break;
						 case "tabD":

							 pageInTab.setTabItemSrc(tabid, "<%=path%>/quato/quatoBscInfo/toListPage.do?id="+id);
							 break;
                     }
            //     };
                 SetIframe_height();
             }
         });

         $.extend(true, pageInApp, {
             pageInTab: pageInTab
         });
    };
    </script>
</body>
</html>
